package pl.perseus.dao;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import pl.perseus.model.Account;
import pl.perseus.model.User;

@Repository
public class AccountDao extends BaseDao<Account> implements IAccountDao{
 
	
	public AccountDao() {
		super("Account");
	}

	@Override
    public Account selectByIdAccount(Long id) {
    	Map<String, Object> map = new HashMap<String, Object>();
    	map.put("id", id);
        return queryForObject("getByIdAccount", map);
    }
	
	@Override
	public Account insertAccount(Account Account){
		return insertBean("insertAccount", Account);
	}
	
	@Override
	public Account getAccountByUser(User user){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("userId", user.getId());
		return queryForObject("getUserAccount", map);
	}
	
	@Override
	public List<Account> getAllAccounts(){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("active", true);
		return queryForList("getByActiveAccount", map);
	}
 
}
